package util.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCTest {

    public static void main(String[] args)  throws SQLException {
        DBConnectionPool dbConnectionPool = DBConnectionPool.getInstance();

        Connection connection = dbConnectionPool.getConnection();
        if(null == connection){
            throw new RuntimeException("数据库连接未正确创建");
        }
        Statement statement = connection.createStatement();
        ResultSet rs = statement.executeQuery("select * from  t_user");
        while (rs.next()){
            String s = rs.getString("username");
            System.out.println("姓名：" + s);
        }
        System.out.println(dbConnectionPool.getNum());
    }
}
